package com.sumainfor.pc.market.controller.rentadviser;

import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.RdWorderInfoService;
import com.sumainfor.pc.market.service.RdWorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 工单详表
 */
@RestController
@RequestMapping("/rentadviser/RdWorderInfo")
public class RdWorderInfoController implements Serializable {
    @Autowired
    private RdWorderInfoService rdWorderInfoService;

    /**
     * 工单确认到达
     */
    @PostMapping("/updateWorderInfoIfArrive")
    public JsonResult updateWorderInfoIfArrive(@RequestBody Map<String,Object>params){

        return rdWorderInfoService.updateWorderInfoIfArrive(params);
    }
    /**
     * 工单完成带看
     */
    @PostMapping("/updateWorderInfoIfArriveWan")
    public JsonResult updateWorderWan(@RequestBody Map<String,Object>params){
        JsonResult result=new JsonResult();
        System.out.println("工单确认到达传递的参数:"+params);
        return  rdWorderInfoService.updateWorderWan(params);
    }
    /**
     * 取消工单
     */
    @PostMapping("/updateWorderInfoState")
    public JsonResult updateWorderInfoState(@RequestBody Map<String,Object>params){
        return  rdWorderInfoService.updateWorderInfoState(params);
    }
    /**
     * 工单转同事
     */
    @PostMapping("/updateTurn")
    public JsonResult updateTurn(@RequestBody Map<String,Object>params){
        return rdWorderInfoService.updateTurn(params);
    }
    /**
     *分页查询租赁顾问评价列表
     * @param
     * @return
     */
    @PostMapping("/getRdWorderEvaList")
    public JsonResult getRdWorderEvaList(@RequestBody Map<String,Object>params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
        pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=rdWorderInfoService.getRdWorderEvaListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>>getCommunityList=rdWorderInfoService.getRdWorderEvaList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     * 修改工单详表的带看时间
     */
    @PostMapping("/updateRdSeTime")
    public JsonResult updateRdSeTime(@RequestBody Map<String,Object>params){
        return rdWorderInfoService.updateRdSeTime(params);
    }
    /**
     * 换房申请列表、租客维护列表 点击创建工单
     */
    @PostMapping("/addRdHouShelf")
    public JsonResult addRdHouShelf(@RequestBody Map<String,Object>params){
        return rdWorderInfoService.addRdHouShelf(params);
    }
    /**
     * 租赁顾问拒绝转单
     */
    @PostMapping("/updateRdTurn")
    public JsonResult updateRdTurn(@RequestBody Map<String,Object>params){
        return rdWorderInfoService.updateRdTurn(params);
    }

}
